from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

# 格式
# engine = create_engine('mysql+pymysql://用户名:密码@主机名:端口/数据库名字')
engine = create_engine('mysql+pymysql://root:python@localhost:3306/19python')
DBSession = sessionmaker(bind=engine)
session = DBSession()
cursor = session.execute("select * from classes;")  # SQLAlchemy也是可以执行SQL语句的，但一般不用，因为我们要用对象来操作SQL
# print(cursor.fetchone())
print(cursor.fetchall())
session.close()
